/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GameObject;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

/**
 *
 * @author Huy
 */
public class StaticImage extends ImageObject {

	int drawWidth;
	int drawHeight;

	public StaticImage(BufferedImage img, int w, int h, int x, int y) {
		init(img);
		drawHeight = h;
		drawWidth = w;
		position = new Point(x, y);
		innerPoint = new Point(0, 0);
		scaleX = 1;
		scaleY = 1;
	}
	public StaticImage(BufferedImage img, int x, int y) {
		init(img);
		drawWidth = img.getWidth();
		drawHeight = img.getHeight();
		position = new Point(x, y);
		innerPoint = new Point(0, 0);
		scaleX = 1;
		scaleY = 1;
	}
	private void init(BufferedImage img) {
		bufferImg = img;
		position = new Point(0, 0);
		scaleX = 1;
		scaleY = 1;
		rotation = 0;
		width = img.getWidth();
		height = img.getHeight();
		innerPoint = new Point(0, 0);
	}
	
	@Override
	public Rectangle getBound() {
		float x = position.x * scaleX;
		float y = position.y * scaleY;

		x = (x - innerPoint.x * scaleX);
		y = (y - innerPoint.y * scaleY);
		return new Rectangle((int) x, (int) y, (int) (drawWidth * scaleX), (int) (drawHeight * scaleY));
	}
	@Override
	public void draw(Graphics2D g, int dx, int dy) {
		Point p = transform(g, dx, dy);
		int x = p.x + dx;
		int y = p.y + dy;

		g.drawImage(bufferImg,
				x, y, x + (int) (drawWidth * scaleX), y + (int) (drawHeight * scaleY),
				0, 0, width, height, null);
	}
}

